import request from "@/utils/request";

export default {
  getTypeList() {
    return request({
      url: "/goodsType/list",
      method: "get",
    });
  },

  addType(goodsType) {
    return request({
      url: "/goodsType",
      method: "post",
      data: goodsType,
    });
  },

  getTypeById(id) {
    return request({
      url: `/goodsType/${id}`,
      method: "get",
    });
  },

  saveType(goodsType) {
    if (goodsType.id == null && goodsType.id == undefined) {
      return this.addType(goodsType);
    }
    return this.updateType(goodsType);
  },

  updateType(goodsType) {
    return request({
      url: `/goodsType`,
      method: "put",
      data: goodsType,
    });
  },

  deleteTypeById(id) {
    return request({
      url: `/goodsType/${id}`,
      method: "delete",
    });
  },
};
